package com.konsung.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.konsung.healthfile.R;

import java.util.List;

/**
 * 类功能：
 */

public class GvMeasureAdapter extends BaseAdapter {

    private final List<String> data;
    private final Context context;
    private final LayoutInflater layoutInflater;

    /**
     * 构造器
     * @param context 上下文
     * @param data 文本数据集
     */
    public GvMeasureAdapter(Context context, List<String> data) {
        this.data = data;
        this.context = context;
        layoutInflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        if (data != null) {
            return data.size();
        }
        return 0;
    }

    @Override
    public Object getItem(int position) {
        return data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = layoutInflater.inflate(R.layout.textview, null);
        TextView text = (TextView) view.findViewById(R.id.text);
        text.setText(data.get(position));

        return view;
    }
}
